package com.common.chris.core;

import org.springframework.stereotype.Component;
import org.springframework.web.filter.OncePerRequestFilter;

import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author wujf
 * @date 2021/10/20
 *
 * 这个是拦截器进入接口的时候先走这个
 */
@Component
public class GlobalResponseHeaderFilter extends OncePerRequestFilter {

    @Override
    protected void doFilterInternal(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, FilterChain filterChain) throws ServletException, IOException {
        // 全局的返回头上加上uid
        httpServletResponse.addHeader("uid", "123");
        filterChain.doFilter(httpServletRequest, httpServletResponse);
    }

}
